package com.taoyibao.hongcanting.ui.webview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.taoyibao.hongcanting.R;
import com.taoyibao.hongcanting.base.BaseRelativeLayout;
import com.taoyibao.hongcanting.constant.ApiRoute;
import com.taoyibao.hongcanting.utils.CodeUtils;

/**
 * @author TangAnna
 * @description:
 * @date :${DATA} 19:04
 */
public class ProtocolArea extends BaseRelativeLayout<Integer> implements View.OnClickListener {

    private TextView mTvLogin;
    private String mTitle;
    private String mUrl;

    public ProtocolArea(Context context) {
        super(context);
    }

    public ProtocolArea(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ProtocolArea(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void initView(Context context, AttributeSet attrs, int defStyleAttr) {
        mTvLogin = findViewById(R.id.tv_protocol_login);
        mTvLogin.setOnClickListener(this);
    }

    @Override
    public void setData(Integer data) {
        switch (data) {
            case 0://登录页面的协议
                mTvLogin.setVisibility(VISIBLE);
                mTvLogin.setText(CodeUtils.getIdString(R.string.string_loginProtocol));
                mTitle = "服务条款";
                mUrl = ApiRoute.LOGIN_WEB_PATH;
                break;
        }

    }

    @Override
    protected int bindLayout() {
        return R.layout.area_protocol;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_protocol_login://登录页面协议
                CommonWebViewActivity.open(getContext(), mTitle, mUrl);
                break;
        }
    }
}
